package com.xintonghua.hongyi.ui.user;

import android.os.Bundle;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.xintonghua.base.ui.BaseActivity;
import com.xintonghua.hongyi.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 作者：wanxianyi
 * 时间：2018/1/13.
 * 包名：com.xintonghua.hongyi.ui.user
 */

public class FeedBackActivity extends BaseActivity {
    @BindView(R.id.edt_feedback)
    EditText edtFeedback;
    @BindView(R.id.tv_count)
    TextView tvCount;
    @BindView(R.id.btn_feedback)
    Button btnFeedback;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_feedback);
        ButterKnife.bind(this);
        onSimpleActionBar();
        setSimpleActionBar("意见反馈");
        initUI();
    }

    @Override
    public void initUI() {
        super.initUI();
        edtFeedback.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void afterTextChanged(Editable editable) {
                if (!TextUtils.isEmpty(getStr(edtFeedback)) && getStr(edtFeedback).length() <= 200) {
                    tvCount.setText(edtFeedback.getText().length() + "/200字");
                }
            }
        });
    }

    @OnClick(R.id.btn_feedback)
    public void onViewClicked() {
        if (TextUtils.isEmpty(getStr(edtFeedback))){
            mToast(" 反馈内容不能为空！");
            return;
        }
        if (getStr(edtFeedback).length()>200){
            mToast(" 反馈内容超限");
            return;
        }
        mToast(" 意见反馈成功！");
        finish();

    }
}
